<html lang="en"><head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
    <title>注册</title>
    <!-- Bootstrap core CSS -->
    <link href="../public/css/bootstrap.min.css" rel="stylesheet">
    <link href="../public/css/register.css" rel="stylesheet">
    <script src="http://cdn.bootcss.com/jquery/1.11.1/jquery.min.js"></script>
</head>
<body>
<{if $error_info}>
<div id="error_info"><{$error_info}></div>
<{/if}>
<div class="container">
    <h2 class="title">注册</h2>
    <form class="form-horizontal" role="form" method="post">
        <div class="form-group">
            <label class="col-sm-2 control-label">昵称</label>
            <div class="col-sm-3">
                <input type="input" class="form-control" id="user_name" name="data[user_name]" placeholder="昵称" required="" onblur="checkUser(this)">
            </div>
            <div class="col-sm-2" id="user_name_result">
                <span style="color: green;display: none" id="user_name_pass">通过</span>
                <span style="color: red;display: none" id="user_name_no_pass">该昵称已经存在</span>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">邮件</label>
            <div class="col-sm-3">
                <input type="email" class="form-control" id="mail_address" name="data[mail_address]" placeholder="邮件" required="">
            </div>
        </div>
        <div class="form-group">
            <label for="inputPassword3" class="col-sm-2 control-label">密码</label>
            <div class="col-sm-3">
                <input type="password" class="form-control" id="psd" name="data[psd]" placeholder="密码" required="">
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-10">
                <button type="submit" class="btn btn-default">注册</button>
            </div>
        </div>
    </form>
</div>
</body>
<script type="text/javascript">
        function checkUser(input){
            var user_name = input.value;
            $.ajax(
                    {
                        type:"post",
                        url:"?_c=register&_a=checkUser",
                        data:"user_name="+user_name,
                        dataType:"json",
                        success:function(retData){
                            if(retData.ret){
                                $("#user_name_pass").show();
                                $("#user_name_no_pass").hide();
                            }else{
                                $("#user_name_pass").hide();
                                $("#user_name_no_pass").show();
                            }
                        }
                    }
            );
        }
</script>
</html>